handle the actual update. add a update_func callback. add a update_func
authorJonathan Blandford <jrb@redhat.com>
Thu, 4 Nov 1999 18:18:07 +0000 (18:18 +0000)
committerJonathan Blandford <jrb@src.gnome.org>
Thu, 4 Nov 1999 18:18:07 +0000 (18:18 +0000)
1999-11-04  Jonathan Blandford  <jrb@redhat.com>

* src/gdk-pixbuf-loader.c (gdk_pixbuf_loader_update): handle the
actual update.
* src/io-png.c (image_begin_load): add a update_func callback.
* src/io-gif.c (image_begin_load): add a update_func callback.
* src/io-tiff.c (image_begin_load): add a update_func callback.

gdk-pixbuf/ChangeLog
gdk-pixbuf/gdk-pixbuf-io.h
gdk-pixbuf/gdk-pixbuf-loader.c
gdk-pixbuf/gdk-pixbuf-loader.h
gdk-pixbuf/io-gif.c
gdk-pixbuf/io-png.c
gdk-pixbuf/io-tiff.c
gtk/gdk-pixbuf-loader.c
gtk/gdk-pixbuf-loader.h

index e1d0c55814a9660ae92e70be3cbf12904d083e42..c9f5c5da653eaa104db25d8a9247033390e4dcd2 100644 (file)
@@ -1,3 +1,11 @@
+1999-11-04  Jonathan Blandford  <jrb@redhat.com>
+
+       * src/gdk-pixbuf-loader.c (gdk_pixbuf_loader_update): handle the
+       actual update.
+       * src/io-png.c (image_begin_load): add a update_func callback.
+       * src/io-gif.c (image_begin_load): add a update_func callback.
+       * src/io-tiff.c (image_begin_load): add a update_func callback.
+
 1999-11-04  Federico Mena Quintero  <federico@redhat.com>
 
        * doc/tmpl/gdk-pixbuf.sgml: Populated.
index 4706106a8b3114486614fb8a116170c82b73bc69..ba42c95ceb342574a8fef30b26f6c0e626b4227b 100644 (file)
@@ -39,6 +39,7 @@ extern "C" {
 \f
 
 typedef void (* ModulePreparedNotifyFunc) (GdkPixbuf *pixbuf, gpointer user_data);
+typedef void (* ModuleUpdatedNotifyFunc) (GdkPixbuf *pixbuf, gpointer user_data, guint x, guint y, guint width, guint height);
 
 typedef struct _GdkPixbufModule GdkPixbufModule;
 struct _GdkPixbufModule {
@@ -49,7 +50,7 @@ struct _GdkPixbufModule {
         GdkPixbuf *(* load_xpm_data) (const gchar **data);
 
         /* Incremental loading */
-        gpointer   (* begin_load)    (ModulePreparedNotifyFunc func, gpointer user_data);
+        gpointer   (* begin_load)    (ModulePreparedNotifyFunc prepare_func, ModuleUpdatedNotifyFunc update_func, gpointer user_data);
         void       (* stop_load)     (gpointer context);
         gboolean   (* load_increment)(gpointer context, const gchar *buf, guint size);
 };
index c62d325f893dfab3df092b311e3d1ecd51c51bcc..eecc8a605f72716e5545089b39cfabb68042b656 100644 (file)
@@ -219,6 +219,21 @@ gdk_pixbuf_loader_prepare (GdkPixbuf *pixbuf, gpointer loader)
        gtk_signal_emit (GTK_OBJECT (loader), pixbuf_loader_signals[AREA_PREPARED]);
 }
 
+static void
+gdk_pixbuf_loader_update (GdkPixbuf *pixbuf, gpointer loader, guint x, guint y, guint width, guint height)
+{
+       GdkPixbufLoaderPrivate *priv = NULL;
+
+       priv = GDK_PIXBUF_LOADER (loader)->private;
+
+       gtk_signal_emit (GTK_OBJECT (loader),
+                        pixbuf_loader_signals[AREA_UPDATED],
+                        x, y,
+                        /* sanity check in here.  Defend against an errant loader */
+                        MIN (width, gdk_pixbuf_get_width (priv->pixbuf)),
+                        MIN (height, gdk_pixbuf_get_height (priv->pixbuf)));
+}
+
 \f
 
 /**
@@ -259,7 +274,7 @@ gdk_pixbuf_loader_load_module(GdkPixbufLoader *loader)
                return 0;
        }
 
-       priv->context = (*priv->image_module->begin_load) (gdk_pixbuf_loader_prepare, loader);
+       priv->context = (*priv->image_module->begin_load) (gdk_pixbuf_loader_prepare, gdk_pixbuf_loader_update, loader);
 
        if (priv->context == NULL) {
                g_warning("Failed to begin progressive load");
index 76997a117d68267e6f379f0ca05b186dab1a1ed1..58fab340f25d2b2ee1bc4c629bb186ae98894240 100644 (file)
@@ -59,7 +59,7 @@ struct _GdkPixbufLoaderClass {
        void (* area_prepared) (GdkPixbufLoader *loader);
 
        void (* area_updated)  (GdkPixbufLoader *loader,
-                                int x, int y, int width, int height);
+                                guint x, guint y, guint width, guint height);
 
        void (* closed)  (GdkPixbufLoader *loader);
 };
index e3dfdb81e67f545d2a879ce5963e62254c8dbc58..5282f03bd028890e4c80c8b27c2d584d1e5fb465 100644 (file)
@@ -121,7 +121,8 @@ struct _GifContext
        FILE *file;
 
        /* progressive read, only. */
-       ModulePreparedNotifyFunc func;
+       ModulePreparedNotifyFunc prepare_func;
+       ModuleUpdatedNotifyFunc update_func;
        gpointer user_data;
        guchar *buf;
        guint ptr;
@@ -650,8 +651,8 @@ gif_get_lzw (GifContext *context)
                                                  context->width,
                                                  context->height);
 
-               if (context->func)
-                       (* context->func) (context->pixbuf, context->user_data);
+               if (context->prepare_func)
+                       (* context->prepare_func) (context->pixbuf, context->user_data);
        }
 
        dest = gdk_pixbuf_get_pixels (context->pixbuf);
@@ -675,7 +676,7 @@ gif_get_lzw (GifContext *context)
                        *(temp+2) = context->color_map [2][(guchar) v];
                }
 
-               if (context->func && context->frame_interlace)
+               if (context->prepare_func && context->frame_interlace)
                        gif_fill_in_lines (context, dest, v);
 
                context->draw_xpos++;
@@ -957,7 +958,8 @@ image_load (FILE *file)
        context->file = file;
        context->pixbuf = NULL;
        context->state = GIF_START;
-       context->func = NULL;
+       context->prepare_func = NULL;
+       context->update_func = NULL;
 
        gif_main_loop (context);
 
@@ -965,7 +967,9 @@ image_load (FILE *file)
 }
 
 gpointer
-image_begin_load (ModulePreparedNotifyFunc func, gpointer user_data)
+image_begin_load (ModulePreparedNotifyFunc prepare_func,
+                 ModuleUpdatedNotifyFunc update_func,
+                 gpointer user_data)
 {
        GifContext *context;
 
@@ -973,7 +977,7 @@ image_begin_load (ModulePreparedNotifyFunc func, gpointer user_data)
        count = 0;
 #endif
        context = g_new (GifContext, 1);
-       context->func = func;
+       context->prepare_func = prepare_func;
        context->user_data = user_data;
        context->file = NULL;
        context->pixbuf = NULL;
index 6dacef8f488b005750e174d5568a2c320848bcf1..643b16c4087387b485c82b23f2081fade0999458 100644 (file)
@@ -257,7 +257,9 @@ struct _LoadContext {
 };
 
 gpointer
-image_begin_load (ModulePreparedNotifyFunc func, gpointer user_data)
+image_begin_load (ModulePreparedNotifyFunc prepare_func,
+                 ModuleUpdatedNotifyFunc update_func,
+                 gpointer user_data)
 {
         LoadContext* lc;
         
@@ -265,7 +267,7 @@ image_begin_load (ModulePreparedNotifyFunc func, gpointer user_data)
         
         lc->fatal_error_occurred = FALSE;
 
-        lc->notify_func = func;
+        lc->notify_func = prepare_func;
         lc->notify_user_data = user_data;
 
         /* Create the main PNG context struct */
index d1e97126cd01568aac5d4a04a8cb00bc9f505f28..91272b5da5d84c1331c2ef16b577294ca7200044 100644 (file)
@@ -37,7 +37,8 @@
 typedef struct _TiffData TiffData;
 struct _TiffData
 {
-       ModulePreparedNotifyFunc func;
+       ModulePreparedNotifyFunc prepare_func;
+       ModuleUpdatedNotifyFunc update_func;
        gpointer user_data;
 
        gchar *tempname;
@@ -69,7 +70,7 @@ image_load_real (FILE *f, TiffData *context)
        pixbuf = gdk_pixbuf_new (ART_PIX_RGB, TRUE, 8, w, h);
 
        if (context)
-               (* context->func) (pixbuf, context->user_data);
+               (* context->prepare_func) (pixbuf, context->user_data);
 
        /* Yes, it needs to be _TIFFMalloc... */
        rast = (uint32 *) _TIFFmalloc (num_pixs * sizeof (uint32));
@@ -108,8 +109,10 @@ image_load_real (FILE *f, TiffData *context)
        _TIFFfree (rast);
        TIFFClose (tiff);
 
-       if (context)
+       if (context) {
                gdk_pixbuf_unref (pixbuf);
+               (* context->update_func) (pixbuf, context->user_data, 0, 0, w, h);
+       }
 
        return pixbuf;
 }
@@ -132,14 +135,17 @@ image_load (FILE *f)
  * the file when it's done.  It's not pretty.
  */
 
+
 gpointer
-image_begin_load (ModulePreparedNotifyFunc func, gpointer user_data)
+image_begin_load (ModulePreparedNotifyFunc prepare_func,
+                 ModuleUpdatedNotifyFunc update_func,
+                 gpointer user_data)
 {
        TiffData *context;
        gint fd;
 
        context = g_new (TiffData, 1);
-       context->func = func;
+       context->prepare_func = prepare_func;
        context->user_data = user_data;
        context->all_okay = TRUE;
        context->tempname = g_strdup ("/tmp/gdkpixbuf-tif-tmp.XXXXXX");
index c62d325f893dfab3df092b311e3d1ecd51c51bcc..eecc8a605f72716e5545089b39cfabb68042b656 100644 (file)
@@ -219,6 +219,21 @@ gdk_pixbuf_loader_prepare (GdkPixbuf *pixbuf, gpointer loader)
        gtk_signal_emit (GTK_OBJECT (loader), pixbuf_loader_signals[AREA_PREPARED]);
 }
 
+static void
+gdk_pixbuf_loader_update (GdkPixbuf *pixbuf, gpointer loader, guint x, guint y, guint width, guint height)
+{
+       GdkPixbufLoaderPrivate *priv = NULL;
+
+       priv = GDK_PIXBUF_LOADER (loader)->private;
+
+       gtk_signal_emit (GTK_OBJECT (loader),
+                        pixbuf_loader_signals[AREA_UPDATED],
+                        x, y,
+                        /* sanity check in here.  Defend against an errant loader */
+                        MIN (width, gdk_pixbuf_get_width (priv->pixbuf)),
+                        MIN (height, gdk_pixbuf_get_height (priv->pixbuf)));
+}
+
 \f
 
 /**
@@ -259,7 +274,7 @@ gdk_pixbuf_loader_load_module(GdkPixbufLoader *loader)
                return 0;
        }
 
-       priv->context = (*priv->image_module->begin_load) (gdk_pixbuf_loader_prepare, loader);
+       priv->context = (*priv->image_module->begin_load) (gdk_pixbuf_loader_prepare, gdk_pixbuf_loader_update, loader);
 
        if (priv->context == NULL) {
                g_warning("Failed to begin progressive load");
index 76997a117d68267e6f379f0ca05b186dab1a1ed1..58fab340f25d2b2ee1bc4c629bb186ae98894240 100644 (file)
@@ -59,7 +59,7 @@ struct _GdkPixbufLoaderClass {
        void (* area_prepared) (GdkPixbufLoader *loader);
 
        void (* area_updated)  (GdkPixbufLoader *loader,
-                                int x, int y, int width, int height);
+                                guint x, guint y, guint width, guint height);
 
        void (* closed)  (GdkPixbufLoader *loader);
 };